﻿using sx_windows.data.bean;
using sx_windows.data.repostory;
using sx_windows.dial;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sx_windows.presenter.dial
{
    class DialPresenter : DialContract.Presenter
    {
        private DialContract.View mView;
        private DialRepository dialRepository;
        public DialPresenter(DialContract.View v)
        {
            this.mView = v;
            this.dialRepository = DialRepository.Instance();
        }
        public void init()
        {
            SxConfigBean bean = dialRepository.GetSxConfig();
            mView.SetSxUserText(bean.User);
            mView.SetSxPasswordText(bean.Password);
            mView.SetNeedSendHeart(bean.SendHeart);
        }

        public void PppoeBtnClick()
        {
            mView.ShowBottomText("正在拨号");
            saveUser();
        }

        private void saveUser()
        {
            string user = mView.GetSxUserText();
            string password = mView.GetSxPasswordText();
            int needSend = mView.GetNeedSendHeart() ? 1 : 0;
            dialRepository.SaveSxConfig(user, password,needSend);
        }

        public void RouterBtnClick()
        {
            mView.ShowBottomText("正在拨号");
            saveUser();
        }

        public void GetPasswordBtnClick()
        {
        }
    }
}
